<template>
  <div class="page-container">
    <div v-if="authorList.length === 0" style="color: #999;">数据加载中...</div>

    <div class="title" v-if="authorList.length !== 0">热门作者</div>
    <div class="author-list">
      <div class="author-item" v-for="item in authorList" :key="item.id">
        <div class="author-avatar" :style="{ 'background-image': `url(${item.web_url})` }"></div>
        <div class="author-msg">
          <div class="author-name">{{ item.user_name }}</div>
          <div class="author-desc">{{ item.desc }}</div>
        </div>
        <div class="author-follow">关注</div>
      </div>
    </div>

  </div>
</template>

<script>
import { getHotAuthors } from '@/api/api'
export default {
  data() {
    return {
      authorList: []
    }
  },
  methods: {

  },
  created() {
    getHotAuthors().
      then(res => {
        // console.log(res.data);
        this.authorList = res.data;
      })
  }
}
</script>

<style scoped lang="less">
.page-container {
  padding: 10vh 10px 7vh;
  box-sizing: border-box;
  background-color: #fff;
  min-height: 100vh;
}

.author-item {
  height: 8vh;
  padding: 1.2vh 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;

  .author-avatar {
    height: 100%;
    aspect-ratio: 1/1;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  }

  .author-msg {
    width: 75%;
    height: 70%;
    margin-left: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    .author-name {
      font-size: 12px;
    }

    .author-desc {
      width: 100%;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      font-size: 8px;
      color: #cdcdcd;
    }
  }

  .author-follow {
    white-space: nowrap;
    font-size: 10px;
    line-height: 1.2;
    padding: 0 7px;
    height: 50%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;

    &::after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 200%;
      height: 200%;
      border: 1px solid #000;
      border-radius: 18px;
      transform: scale(0.5);
      transform-origin: 0 0;
      box-sizing: border-box;
    }
  }
}
</style>